package VN.EDU.IMIC.DEVELOPER.VUVANLUANLEVEL2.EXR0102;

import java.util.Scanner;

public class views {

	public static void main(String[] args) {
		//khai bao doi tuong chua tham so cho tinh toan
rectaninformation objrectan = new rectaninformation();
System.out.println("Ban muon thuc hien phep toan voi hinh nao ?  1-Tam giac hay 2-Lucgiac");
Scanner sc = new Scanner(System.in);
int phepchon = sc.nextInt();
if(phepchon == 1){
System.out.println("Moi nhap canh thu nhat cua tam giac");
objrectan.setSide1(sc.nextDouble());
System.out.println("Moi nhap canh thu hai cua tam giac");
objrectan.setSide2(sc.nextDouble());
System.out.println("Moi nhap canh thu ba cho tam giac");
objrectan.setSide3(sc.nextDouble());

   //Khai bao va khoi tao doi tuong cua controller
controller objcontroller = new controller();
if (objrectan.getSide1() + objrectan.getSide2() - objrectan.getSide3() <= 0||objrectan.getSide2() + objrectan.getSide3() - objrectan.getSide1() <= 0||
objrectan.getSide1() + objrectan.getSide3() - objrectan.getSide2() <= 0){System.out.println("Ba canh tren khong phai ba canh tam giac. Moi nhap lai");
	}
else {
	System.out.println(objcontroller.calculatortostring(objrectan)); 
	System.out.println("Co dien tich la :" + objcontroller.calculatorarea(objrectan));
	System.out.println("Co chu vi la : "+ objcontroller.calculatorperimeter(objrectan));
}
}
else {if(phepchon == 2){
	System.out.println("Moi nhap canh cho luc giac deu : ");
	objrectan.setSidelucgiac(sc.nextDouble());
	controller objcontroller = new controller();
	System.out.println("Dien tich cua luc giac deu canh " + objrectan.getSidelucgiac() + "  la : " + objcontroller.calculatorarealucgiac(objrectan));
	System.out.println("Chu vi cua luc giac deu canh "+ objrectan.getSidelucgiac() + " la : "+ objcontroller.calculatorperimeterlucgiac(objrectan));
	} else {System.out.println("Ban chon sai lam tren tam giac hay tren luc giac. Moi chon lai 1 hoac 2");}

}
}
}
